package hezi.common;

import java.io.File;

public class SystemConfig {
	private static SystemConfig instance = new SystemConfig();
	private String webRootPath;
	private String warPath;
	private SystemConfig(){}
	
	public static SystemConfig getInstance()	{
		return instance;
	}
	
	
	public void setWebRootPath(String webRootPath) {
		this.webRootPath = webRootPath;
	}
	public void setWarPath(String warPath) {
		String fileSep = System.getProperty("file.separator");
		StringBuffer stringBuffer = new StringBuffer(warPath);
		this.warPath = stringBuffer.substring(0, warPath.lastIndexOf(fileSep)+1);
	}
	
	
	
	public String getSysDBPath()
	{
		File file = new File( getWarPath() + "\\sys\\");
		if(!file.exists()){
			file.mkdirs();
		}
		return  getWarPath() + "\\sys\\";
	}
	public String getWebRootPath() {
		return webRootPath;
	}
	public String getImagePath(){
		return getWebRootPath() + "\\images\\";
	}
	
	public String getDbPath(){
		String path = getWarPath() + "db\\";
		
		File dir = new File(path);
		if(!dir.exists()){
			dir.mkdirs();
		}
		
		return path;
	}
	public String getDownloadImagePath()
	{
		return getWarPath() + "downloadimages\\";
	}
	public String getTempletePath()
	{
		return getWebRootPath() + "\\templete\\";
	}
	public String getConfigPath()
	{
		return getWebRootPath() + "\\WEB-INF\\classes\\";
	}
	public String getWarPath() {
		return warPath;
	}
}
